<%@ Page Language="C#" MasterPageFile="~/MasterDefault.master" AutoEventWireup="true"
    Inherits="TeamTime.CompaniesForm" Title="TeamTime - Companies Maintenance"
    StylesheetTheme="Default" CodeBehind="CompaniesForm.aspx.cs" %>

<%@ Register Src="CompanyFormControl.ascx" TagName="CompanyFormControl" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="true">
        <Services>
            <asp:ServiceReference Path="AutoComplete.asmx" />
        </Services>
    </asp:ScriptManager>
    <clib:UpdatePanelExtender runat="server" ID="UpdatePanelExtender1" UpdateMode="Conditional">
        <ContentTemplate>
            <br />
            <h3>
                Companies &nbsp; &nbsp;<asp:Button runat="server" ID="btnAddNew" Text="Add New" OnClick="btnAddNew_Click"
                    CausesValidation="False" />
                <asp:HyperLink ID="hypAddEnterprise" runat="server" NavigateUrl="~/EnterpriseRegistrationForm1.aspx">Add new Enterprise wizard</asp:HyperLink>
            </h3>
            <asp:Button runat="server" ID="btnAddDummy" Text="Add New" Visible="true" Style="display: none;" />
            <clib:ModalPopupPanel runat="server" ID="popUp1" TargetControlID="btnAddDummy" Width="580"
                Title="Company">
                <uc1:CompanyFormControl ID="CompanyFormControl1" runat="server" OnLoadDupClicked="CompanyFormControl1_LoadDupClicked"
                    OnSaveClicked="CompanyFormControl1_SaveClicked" OnCompanyTypeChanged="CompanyFormControl1_CompanyTypeChanged" />
                <asp:TextBox ID="txtID" runat="server" ReadOnly="true" BackColor="#E0E0E0" BorderStyle="None"
                    Visible="false"></asp:TextBox>&nbsp;
            </clib:ModalPopupPanel>
            <table id="tblHead" cellspacing="0" cellpadding="1" border="0" runat="server" style="width: 80%;">
                <tr>
                    <td>
                        Search for
                    </td>
                    <td colspan="4">
                        <asp:TextBox ID="txtSearchFor" runat="server" MaxLength="100" Width="200px"></asp:TextBox>
                        &nbsp;&nbsp;&nbsp;&nbsp;Search in notes &nbsp;<asp:CheckBox ID="chkSearchNotes" runat="server"
                            Checked="false" />
                        &nbsp;&nbsp; Search in activities&nbsp;<asp:CheckBox ID="chkSearchActivities" runat="server"
                            Checked="false" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Company Type
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlType" runat="server">
                            <asp:ListItem Text="<Any>" Value="Any"></asp:ListItem>
                            <asp:ListItem>Enterprises</asp:ListItem>
                            <asp:ListItem>Suppliers</asp:ListItem>
                            <asp:ListItem>Others</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td>
                        Province
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlProvinceIDFilter" runat="server">
                        </asp:DropDownList>
                    </td>
                    <td>
                        <asp:Button ID="btnSearch" runat="server" Text="Search >>" CausesValidation="False"
                            OnClick="btnSearch_Click"></asp:Button>
                    </td>
                </tr>
            </table>
            <br />
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" SkinID="GridView"
                AllowPaging="True" PageSize="20" AllowSorting="True" DataKeyNames="ID" OnPageIndexChanging="GridView1_PageIndexChanging"
                OnRowCommand="GridView1_RowCommand" OnRowDeleting="GridView1_RowDeleting">
                <Columns>
                    <asp:TemplateField HeaderText="" SortExpression="ID">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkID" runat="server" CausesValidation="false" CommandName="Select"
                                Text="Edit" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.ID") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="CompanyName" HeaderText="Company Name" SortExpression="CompanyName">
                    </asp:BoundField>
                    <asp:BoundField DataField="TelephoneNumber" HeaderText="Tel"></asp:BoundField>
                    <asp:BoundField DataField="FaxNumber" HeaderText="Fax"></asp:BoundField>
                    <asp:BoundField DataField="ContactPerson" HeaderText="Contact"></asp:BoundField>
                    <asp:BoundField DataField="Province" HeaderText="Province"></asp:BoundField>
                    <asp:TemplateField HeaderText="Email" SortExpression="EmailAddress">
                        <ItemTemplate>
                            <asp:HyperLink ID="hypEmail" runat="server" NavigateUrl='<%# "mailto:" + DataBinder.Eval(Container, "DataItem.EmailAddress") %>'
                                Text='<%# DataBinder.Eval(Container, "DataItem.EmailAddress") %>'><%# DataBinder.Eval(Container, "DataItem.EmailAddress") %></asp:HyperLink>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="Notes" HeaderText="Notes"></asp:BoundField>
                    <asp:BoundField DataField="RecordDate" HeaderText="Record Date" DataFormatString="{0:yyyy/MM/dd}"
                        Visible="False"></asp:BoundField>
                    <%--<asp:TemplateField>
                        <ItemTemplate>
                            <asp:LinkButton runat="server" CausesValidation="false" CommandName="Delete" Text="Delete"
                                OnClientClick='JavaScript:return confirm("Are you sure?");'></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>--%>
                    
<%--                    <asp:BoundField DataField="Activities" HeaderText="Activities"></asp:BoundField>--%>
                </Columns>
                <EmptyDataTemplate>
                    No records found</EmptyDataTemplate>
                <PagerTemplate>
                    <table width="100%">
                        <tr>
                            <td style="text-align: left; font-size: 11px; width: 100px;">
                                Page
                                <asp:Label ID="lblPageIndex" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1  %>' />
                                of
                                <asp:Label ID="lblPageCount" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageCount  %>' />
                            </td>
                            <td style="text-align: center; font-size: 11px;">
                                <asp:Panel ID="pnlPager" runat="server" DefaultButton="lnkGo">
                                    <asp:LinkButton ID="lnkFirst" runat="server" CausesValidation="False" CommandArgument="First"
                                        CommandName="Page" Text="Page 1" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkPrev" runat="server" CausesValidation="False" CommandArgument="Prev"
                                        CommandName="Page" Text="<< Prev" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkNext" runat="server" CausesValidation="False" CommandArgument="Next"
                                        CommandName="Page" Text="Next >>" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkLast" runat="server" CausesValidation="False" CommandArgument="Last"
                                        CommandName="Page" Text='<%# "Page "+ ((GridView)Container.Parent.Parent).PageCount  %>' />&nbsp;&nbsp;&nbsp;
                                    <asp:TextBox ID="txtNewPageIndex" runat="server" Width="20px" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1  %>' />
                                    <asp:LinkButton ID="lnkGo" runat="server" CausesValidation="False" CommandArgument="-1"
                                        CommandName="Page" Text="Go" /><!-- here set the CommandArgument of the Go Button to '-1' as the flag -->
                                </asp:Panel>
                            </td>
                        </tr>
                    </table>
                </PagerTemplate>
            </asp:GridView>
        </ContentTemplate>
    </clib:UpdatePanelExtender>
</asp:Content>
